package com.lan.mock15.d;

import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int m = input.nextInt();
		
		int[] left = new int[m];
		int[] right = new int[m];
		int[] a = new int[n + 2];
		int[] s = new int[n + 2];
		for (int i = 0; i < m; i ++) {
			left[i] = input.nextInt();
			right[i] = input.nextInt();
			
			a[left[i]] ++;
			a[right[i] + 1] --;
		}
		int sum = 0;
		for (int i = 1; i <= n; i ++) {
			a[i] += a[i - 1];
			if (a[i] == 0) {
				sum ++;
			}
			s[i] = s[i - 1] + (a[i] == 1 ? 1 : 0);
		}
		
		for (int i = 0; i < m; i ++) {
			System.out.println(s[right[i]] - s[left[i] - 1] + sum);
		}
	}
}
